# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: KokaKiwi <kokakiwi+aur@kokakiwi.net>
# Contributor: Mohammad AlSaleh <CE.Mohammad.AlSaleh at gmail dot com>

pkgname=lua-language-server
pkgver=3.7.3
pkgrel=1
license=('MIT')
pkgdesc='Lua Language Server coded by Lua'
url=https://luals.github.io
arch=('loong64' 'x86_64')
depends=('bash' 'gcc-libs')
makedepends=('git' 'ninja' 'rsync')
source=(
  "git+https://github.com/LuaLS/lua-language-server.git#tag=$pkgver"
  'git+https://github.com/actboy168/luamake.git'
  'git+https://github.com/actboy168/bee.lua.git'
  'git+https://github.com/sqmedeiros/lpeglabel.git'
  'git+https://github.com/love2d-community/love-api.git'
  'git+https://github.com/bjornbytes/lovr-docs.git'
  'git+https://github.com/CppCXY/EmmyLuaCodeStyle.git'
  'git+https://github.com/actboy168/json.lua.git'
  'git+https://github.com/LuaCATS/OpenResty.git'
  'git+https://github.com/LuaCATS/bee.git'
  'git+https://github.com/LuaCATS/busted.git'
  'git+https://github.com/LuaCATS/Cocos4.0.git'
  'git+https://github.com/LuaCATS/Defold.git'
  'git+https://github.com/LuaCATS/Jass.git'
  'git+https://github.com/LuaCATS/luafilesystem.git'
  'git+https://github.com/LuaCATS/love2d.git'
  'git+https://github.com/LuaCATS/lovr.git'
  'git+https://github.com/LuaCATS/luaecs.git'
  'git+https://github.com/LuaCATS/luassert.git'
  'git+https://github.com/LuaCATS/skynet.git'
  'git+https://github.com/LuaCATS/ffi-reflect.git'
  'git+https://github.com/LuaCATS/luv.git'
  'wrapper'
)
b2sums=('SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        '72f906db083db75d5ed14fb7198e9fa2e46cc281a5978eaa6ce4c5f4735206d65894ed45a99c515622862e6fa21225f76839910c1eae01a6399f142263f2bdda')

prepare() {
  cd $pkgname
  git submodule init
  for i in ../{luamake,bee.lua,lpeglabel,love-api,EmmyLuaCodeStyle,json.lua}; do
    git config submodule.3rd/"${i##../}".url "$i"
  done
  for i in ../{OpenResty,bee,busted,Cocos4.0,Defold,Jass,love2d,lovr,luaecs,luassert,skynet,ffi-reflect,luv}; do
    git config submodule.meta/3rd/"${i##../}".url "$i"
  done
  git config submodule.3rd/lovr-api.url ../lovr-docs
  git config submodule.meta/3rd/lfs.url ../luafilesystem
  git -c protocol.file.allow=always submodule update
  cd 3rd/luamake
  git submodule init
  git config submodule.3rd/bee.lua.url ../../../bee.lua
  git -c protocol.file.allow=always submodule update
}

build() {
  cd $pkgname
  ninja -C 3rd/luamake -f compile/ninja/linux.ninja
  ./3rd/luamake/luamake rebuild
}

package() {
  install -D wrapper "$pkgdir"/usr/bin/$pkgname
  cd $pkgname
  install -Dt "$pkgdir"/usr/lib/$pkgname/bin bin/$pkgname
  install -m644 -t "$pkgdir"/usr/lib/$pkgname/bin bin/main.lua
  install -m644 -t "$pkgdir"/usr/lib/$pkgname {debugger,main}.lua
  rsync -r --exclude=.git locale meta script "$pkgdir"/usr/lib/$pkgname
  install -Dm644 -t "$pkgdir"/usr/share/licenses/$pkgname LICENSE
}

# vim:set ts=2 sw=2 et:
